﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using System;

namespace AbpCompanyName.AbpProjectName.Migrations;

public partial class Upgrade_ABP_4_2_0 : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropColumn(
            name: "LastLoginTime",
            table: "AbpUsers");

        migrationBuilder.DropColumn(
            name: "LastLoginTime",
            table: "AbpUserAccounts");

        migrationBuilder.AddColumn<string>(
            name: "ReturnValue",
            table: "AbpAuditLogs",
            nullable: true);

        migrationBuilder.CreateTable(
            name: "AbpOrganizationUnitRoles",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                TenantId = table.Column<int>(nullable: true),
                RoleId = table.Column<int>(nullable: false),
                OrganizationUnitId = table.Column<long>(nullable: false),
                IsDeleted = table.Column<bool>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => x.Id);
            });

        migrationBuilder.CreateIndex(
            name: "IX_AbpOrganizationUnitRoles_TenantId_OrganizationUnitId",
            table: "AbpOrganizationUnitRoles",
            columns: new[] { "TenantId", "OrganizationUnitId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpOrganizationUnitRoles_TenantId_RoleId",
            table: "AbpOrganizationUnitRoles",
            columns: new[] { "TenantId", "RoleId" });
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropTable(
            name: "AbpOrganizationUnitRoles");

        migrationBuilder.DropColumn(
            name: "ReturnValue",
            table: "AbpAuditLogs");

        migrationBuilder.AddColumn<DateTime>(
            name: "LastLoginTime",
            table: "AbpUsers",
            nullable: true);

        migrationBuilder.AddColumn<DateTime>(
            name: "LastLoginTime",
            table: "AbpUserAccounts",
            nullable: true);
    }
}
